package com.candoit.webapps.pricing.bean.adapters;

import java.text.DecimalFormat;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public class DoubleConverter implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		
		Double result = null;
		result = Double.valueOf(value); 
		
		return result;
	}

	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		DecimalFormat twoDForm = new DecimalFormat("#.##");
		
		Double numero = (Double)value;
		
		String result = null;
		
		result = twoDForm.format(numero); 
		
		return result;
	}

}
